package com.ruoyi.dataprocess.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.dataprocess.domain.DbOrder;
import com.ruoyi.dataprocess.service.IDbOrderService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 订单信息Controller
 * 
 * @author chenda
 * @date 2024-01-26
 */
@RestController
@RequestMapping("/order")
public class DbOrderController extends BaseController
{
    @Autowired
    private IDbOrderService dbOrderService;

    /**
     * 查询订单信息列表
     */
    @RequiresPermissions("dataprocess:order:list")
    @GetMapping("/list")
    public TableDataInfo list(DbOrder dbOrder)
    {
        startPage();
        List<DbOrder> list = dbOrderService.selectDbOrderList(dbOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单信息列表
     */
    @RequiresPermissions("dataprocess:order:export")
    @Log(title = "订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DbOrder dbOrder)
    {
        List<DbOrder> list = dbOrderService.selectDbOrderList(dbOrder);
        ExcelUtil<DbOrder> util = new ExcelUtil<DbOrder>(DbOrder.class);
        util.exportExcel(response, list, "订单信息数据");
    }

    /**
     * 获取订单信息详细信息
     */
    @RequiresPermissions("dataprocess:order:query")
    @GetMapping(value = "/{序号}")
    public AjaxResult getInfo(@PathVariable("序号") Long 序号)
    {
        return success(dbOrderService.selectDbOrderBy序号(序号));
    }

    /**
     * 新增订单信息
     */
    @RequiresPermissions("dataprocess:order:add")
    @Log(title = "订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DbOrder dbOrder)
    {
        return toAjax(dbOrderService.insertDbOrder(dbOrder));
    }

    /**
     * 修改订单信息
     */
    @RequiresPermissions("dataprocess:order:edit")
    @Log(title = "订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DbOrder dbOrder)
    {
        return toAjax(dbOrderService.updateDbOrder(dbOrder));
    }

    /**
     * 删除订单信息
     */
    @RequiresPermissions("dataprocess:order:remove")
    @Log(title = "订单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{序号s}")
    public AjaxResult remove(@PathVariable Long[] 序号s)
    {
        return toAjax(dbOrderService.deleteDbOrderBy序号s(序号s));
    }
}
